﻿/*
 * QWFP (QWine For Pajak)
 * Copyright (C) 2010 Wish Enterprise

 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * 
 * Contact Us:
 * E-Mail   : contact@wishenterprise.com
 * Website  : http://www.wishenterprise.com
 * Telp.    : 0276 - 3339945
 * Mobile   : 0815 4850 3620
 * 
 * */
using System;
using System.Text;

namespace QWTouchPanel
{
    /// <summary>
    /// Thermal / DOT Matrix Direct Printing 
    /// </summary>
    public static class DirectPrint
    {
        /// <summary>
        /// Opens the cash drawer.
        /// </summary>
        /// <returns></returns>
        public static String OpenCashDrawer()
        {
            var sequence = new StringBuilder();

            sequence.Append((char) 27);

            sequence.Append((char) 112);

            sequence.Append((char) 0);

            sequence.Append((char) 25);

            sequence.Append((char) 250);

            return sequence.ToString();
        }

        /// <summary>
        /// Initializes the printer.
        /// </summary>
        /// <returns></returns>
        public static String InitializePrinter()
        {
            var sequence = new StringBuilder();

            sequence.Append((char) 27);

            sequence.Append((char) 64);

            return sequence.ToString();
        }

        /// <summary>
        /// Prints the center text.
        /// </summary>
        /// <returns></returns>
        public static String PrintCenterText()
        {
            var sequence = new StringBuilder();

            sequence.Append((char) 27);

            sequence.Append((char) 97);

            sequence.Append((char) 1);

            return sequence.ToString();
        }

        /// <summary>
        /// Prints the left text.
        /// </summary>
        /// <returns></returns>
        public static String PrintLeftText()
        {
            var sequence = new StringBuilder();

            sequence.Append((char) 27);

            sequence.Append((char) 97);

            sequence.Append((char) 0);


            return sequence.ToString();
        }

        /// <summary>
        /// Cuts the paper.
        /// </summary>
        /// <returns></returns>
        public static String CutPaper()
        {
            var sequence = new StringBuilder();

            sequence.Append((char) 27);

            sequence.Append((char) 105);

            sequence.Append((char) 0);

            sequence.Append((char) 25);


            return sequence.ToString();
        }


        public static String FeedPaper(int pNumLines)
        {
            var sequence = new StringBuilder();

            sequence.Append((char) 27);

            sequence.Append((char) 100);

            sequence.Append((char) pNumLines);


            return sequence.ToString();
        }

        public static string Bold(bool isBool)
        {
            var sequence = new StringBuilder();

            sequence.Append((char) 27);

            sequence.Append((char) 69);

            sequence.Append(isBool ? (char) 1 : (char) 0);

            return sequence.ToString();
        }

        public static string Strong(int val)
        {
            var sequence = new StringBuilder();

            sequence.Append((char) 29);

            sequence.Append((char) 33);

            sequence.Append((char) val);

            return sequence.ToString();
        }
    }
}